MC-10 Operation and Language Reference Manual Chapter 7

7/DATA OUTPUT TO THE TV AND PRINTER All the example programs in the previous chapters used one Micro Color BASIC command to display information on the TV Screen. That command - PRINT - can take a variety of forms, including one form that lets you output information on a printer (if one is connected to the MC-10). The PRINT Command The command that displays ("prints") information on the Screen is PRINT and it's used like this:
PRINT message message is either a string value or a numeric expression. If message is a string value, it must be enclosed in quotation marks and will be displayed exactly as it is. If message is a numeric expression, it will not be in quotes and will be treated as a number.
As you've already seen, PRINT can be used with either strings or numbers. In technical terms, PRINT simply outputs to the display. This means that anything with the word PRINT before it generates a display on the TV. PRINTing Strings and Numbers If you type in a string such as COMPUTER, but do not enclose it in quotes, the Computer will treat the word as a number, assign it a value of zero, and display that value. Try it and the Screen will look like this: OK PRINT COMPUTER 0 OK Tell the MC-10 to print 10 COMPUTER: OK PRINT 10 COMPUTER 10 0 OK In this case, the MC-10 treated the number 10 as a number and printed what you told it to print. The word COMPUTER, however, was also treated as a number and assigned the value of zero; that value was then printed. There Has To Be An Easier Way... PRINT is a command you'll use constantly. Notice that directly over the [9] key is the word PRINT. Instead of typing PRINT over and over, just type: [CONTROL][9] When you do, your Screen will look like this: OK PRINT with the Cursor blinking after the word PRINT, waiting for you to add on what you want printed. You can then type a string or numeric expression and press [ENTER]: OK PRINT "USE THE CONTROL COMMAND K EYS WHEN YOU CAN" [ENTER] USE THE CONTROL COMMAND KEYS WHE N YOU CAN OK Notice the TV Screen "wraps-around" when it reaches the 32nd character (or space) at the right side of the Screen. This doesn't effect operation of your Computer or the processing of your program at all. It's perfectly normal. One More Time... Unlike other Micro Color BASIC commands, PRINT has an additional method of being typed into the MC-10. Instead of typing the word itself or pressing [CONTROL][9], just type a question mark (?). For instance, when you type: ? 100 [ENTER] The TV will display: 100 When you get further into programming, you'll notice that you can use a ? as a PRINT statement in a program line. Then, when you "clear" (or erase) the Screen and list the program, Micro Color BASIC will automatically substitute the word PRINT for the ?. PRINTing Alternatives In the PRINT examples you've seen so far, the MC-10 has displayed a message at the left side of the Screen. Micro Color BASIC also allows you to print information at other Screen locations. You can either use pre-determined PRINT positions, or you can specify where you want information to be PRINTed. PRINT Punctuation By adding a punctuation mark to PRINT, you can use a pre-determined PRINT format. PRINTing Without Punctuation Type in the following short program: 10 PRINT "1ST PRINT" 20 PRINT "2ND PRINT" 30 PRINT "3RD PRINT" When you RUN the program, the TV will look like this: 1ST PRINT 2ND PRINT 3RD PRINT OK Notice that nothing has changed in the printing. The second PRINT command simply goes to the next line and displays the message. PRINTing With a Comma Now type NEW [ENTER] to erase the program; then type in this program: 10 PRINT "1ST PRINT", 20 PRINT "2ND PRINT", 30 PRINT "3RD PRINT", 40 END The only difference between this program and the previous one is the comma (,) at the end of line 10, 20, and 30. When you RUN the program, the display will look like this: 1ST PRINT 2ND PRINT 3RD PRINT OK When you use a PRINT with a comma, Micro Color BASIC skips to the 17th position ("row") to start printing the next PRINT item. If a PRINT item has more than 17 characters, Micro Color BASIC will go to the next line when printing the next PRINT item.
PRINT Suffix | PRINT Format
No punctuation | Prints the message on the next line in columns (one message per line)
Comma (,) | Prints the message in rows (16 spaces before the first character of the next row)
Semi-Colon (;) | Prints the message without spaces between the next message item
@ position | Prints at the Screen position you specify. position is a numeric expression between 0 and 511
TAB ( ) | Prints at the specified column position
Table 2
PRINTing With a Semi-Colon Type NEW [ENTER] to erase the program. Now type in this program: 10 PRINT "1ST PRINT"; 20 PRINT "2ND PRINT"; 30 PRINT "3RD PRINT"; 40 END When you RUN the program this time, the display will look like this: 1ST PRINT2ND PRINT3RD PRINT OK Notice how the PRINT items are bunched up together. If you want a space between PRINT items when you use a semicolon, include it in the string (i.e., within the quotation marks). Line 10, for instance, would look like this: 10 PRINT "1ST PRINT "; PRINT @ All of the PRINT formats we've discussed so far have used pre-determined PRINT positions. There is one PRINT variation, however, that lets you specify exactly where on the Screen you want printing to take place.
PRINT@ position, message position specifies a valid Screen print position where printing is to begin and is a numeric expression between 0 and 511. position must be followed by a comma. message is the message you want printed and is a numeric or data string.
When your TV is connected to the MC-10, the TV's Screen is divided into 512 (0-511) individual print positions. With PRINT@, you can specify the exact position you want printing to begin. Figure 18 defines those print positions. The 512 Screen positions start at 0 (in the upper-left corner of the Screen) and increase as you move to the right. The upper-right corner is position 31. Counting then "wraps-around" to the beginning of the next line. Position 511 is the last position (the lower-right corner). Type NEW [ENTER] and try this short program: 10 PRINT @ 230, "PRINT @ POSITION 230" RUN the program and the message will be printed near the center of the Screen beginning at position 230. PRINT TAB( ) By adding the TAB( ) suffix to the PRINT command, you can tell Micro Color BASIC exactly where you want to start printing.
PRINT TAB(column) column specifies a position print column on the TV display and is a numeric expression between 0-255.
There are 32 (0-31) print columns on the TV display and you can specify printing to start at any one of those columns. If column is greater than 31, Micro Color BASIC "wraps around" to the next line and starts printing there. For instance, PRINT TAB(60) starts printing near the last position on the next line. PRINT TAB( ) is useful for printing tables that have rows and columns. Try this example: 10 PRINT TAB(10)"A";: PRINT TAB(20)"B" 20 PRINT TAB(8)"1000";: PRINT TAB(18)"2000" 30 PRINT TAB(8)"4000";: PRINT TAB(18)"5000" 40 END When you RUN this program, you have a table that looks something like this: A B 1000 2000 4000 5000 OK Notice the TAB value (column) doesn't have to be a numeric constant-it can be any numeric expression. This means a single TAB(column) function in your PRINT statement can generate any number of TAB positions. The LPRINT Command The MC-10 can be used with any Radio Shack printer that has a 4-pin Serial Interface Connector. For details about connecting the MC-10 to a printer, see the "Operation" section of this manual. Once a printer is connected to the Computer, use the Micro Color BASIC command LPRINT to get printed copies of the data. (Remember that LLIST will provide printed copies of program listings.)
LPRINT message message is either a string value or a numeric expression. If message is a string value, it must be enclosed in quotation marks and will be displayed exactly as it is. If message is a numeric expression, it will not be in quotes and will be treated as a number.
LPRINT can be used exactly like PRINT. The only exception to this rule is that you cannot LPRINT@. Important Note! If you use the LPRINT command and the printer is not connected (or if one is connected but is off-line or the power is off), the Computer will "hang-up". When this occurs, you must press RESET (on the back of the Computer) before the OK prompt will reappear. If you've connected a printer to the MC-10, try this short program: 10 LPRINT "THIS WILL BE PRINTED ON THE PRINTER" 20 LPRINT "AND SO WILL THIS"; :REM SEMICOLON 30 LPRINT "AND SO WILL THIS", :REM COMMA 40 LPRINT TAB(15) "AND FINALLY THIS" :REM TAB 50 END LPRINTing Lowercase Letters In the "Operation" section of this manual, we discussed the difference between upper-and lowercase letters. If you remember, we mentioned that even though lowercase letters could not be displayed on the Screen, they could be printed on the printer. Note: Micro-Color BASIC does not recognize lowercase commands. To print out lowercase letters, press the key-combination of [SHIFT][0] just before you type in the letters which are to be lowercase. For instance, type: 10 LPRINT "THIS IS UPPERCASE." 20 LPRINT " Now press [SHIFT][0] and finish the line: THIS IS LOWERCASE." Notice that lowercase letters are displayed in "reverse video". To get back to Normal Mode, press [SHIFT][0] again. RUN the program to produce a print-out like this: THIS IS UPPERCASE... this is lowercase. You must switch back to uppercase letters before you can enter the RUN command.

Comments should be directed to the following email address:
dsbrain@neosplice.com